package com.acwing.partition18;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/4/7 20:40
 */
public class AC1775丢失的牛 {

    private static int x, y;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        x = Integer.parseInt(ss[0]);
        y = Integer.parseInt(ss[1]);
        int ans = 0, d = 1, flag = 1;
        while (true) {
            if ((flag == 1 && y >= x && y <= x + d) || (flag == -1 && y <= x && x <= y + d)) {
                ans += Math.abs(y - x);
                break;
            } else {
                d <<= 1;
                flag = -flag;
                ans += d;
            }
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
